﻿<Window x:Class="Patterns4Net.ArchitectureExplorer.Views.ShellView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock" 
             xmlns:Utils="clr-namespace:Patterns4Net.ArchitectureExplorer.Views.Utils" mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"                     
             Title="Patterns4Net: Architecture Explorer"
             Width="{Binding WindowWidth, Mode=OneWayToSource}"
             Height="{Binding WindowHeight, Mode=OneWayToSource}">
    <Window.Resources>
        <ResourceDictionary Source="Graph/GraphElementsTemplates.xaml" />
    </Window.Resources>    
    <Grid>        
        <Grid.RowDefinitions>            
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="26"/>
        </Grid.RowDefinitions>        

        <Border BorderBrush="#FFD0D0FF" BorderThickness="0, 0, 0, 1">
            <Grid Background="#FFD6E2F8" Margin="0,0,0,0">
                <Grid.Resources>
                    <Utils:BooleanToVisibilityMultiConverter x:Key="BooleanToVisibilityMultiConverter"/>
                </Grid.Resources>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0" Grid.Column="0">
                    <StackPanel Orientation="Horizontal" Height="107" x:Name="ToolbarStackPanel">
                        <StackPanel.Visibility>
                            <MultiBinding Converter="{StaticResource BooleanToVisibilityMultiConverter}">
                                <Binding ElementName="ShowRibbon" Path="IsChecked"/>
                                <!-- <Binding ElementName="RibbonWrapperButton" Path="IsMouseOver"/> -->
                            </MultiBinding>
                        </StackPanel.Visibility>
                        
                        <StackPanel.Resources>
                            <Style x:Key="GroupHeading" TargetType="TextBlock">
                                <Setter Property="TextAlignment" Value="Center"/>
                                <Setter Property="Margin" Value="0, 0, 0, 0"/>
                            </Style>
                            <Style x:Key="GroupHeadingBorder" TargetType="Border">
                                <Setter Property="Margin" Value="0, 12, 0, 0"/>
                                <Setter Property="Padding" Value="0"/>
                                <Setter Property="Background" Value="#FFD0D0FF"/>
                                <Setter Property="BorderBrush" Value="#FFD0D0FF"/>
                                <Setter Property="CornerRadius" Value="4"/>
                            </Style>
                            <Style x:Key="ButtonHeading" TargetType="TextBlock">
                                <Setter Property="TextAlignment" Value="Center"/>
                                <Setter Property="FontSize" Value="10"/>
                            </Style>
                            <Style x:Key="ButtonImage" TargetType="Image">
                                <Setter Property="Width" Value="48"/>
                                <Setter Property="Height" Value="48"/>
                            </Style>
                            <Style x:Key="ButtonBorder" TargetType="Border">
                                <Setter Property="Margin" Value="5, 0, 5, 0"/>
                                <Setter Property="BorderThickness" Value="1"/>
                                <Setter Property="CornerRadius" Value="3"/>
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Background" Value="#99E0AF1B"/>
                                        <Setter Property="BorderBrush" Value="#DDE0AF1B"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                            <Style x:Key="GroupBorder" TargetType="Border">
                                <Setter Property="BorderThickness" Value="0, 0, 1, 0"/>
                                <Setter Property="BorderBrush" Value="Black"/>
                                <Setter Property="Height" Value="95"/>
                                <Setter Property="Margin" Value="2,0,2,0"/>
                                <Setter Property="BorderBrush" Value="#FFC6BED4"/>
                                <Setter Property="CornerRadius" Value="4"/>
                                <Setter Property="BorderThickness" Value="1"/>
                            </Style>
                            <Style x:Key="GroupPanel" TargetType="StackPanel">
                                <Setter Property="Margin" Value="0"/>
                                <Setter Property="VerticalAlignment" Value="Bottom"/>
                            </Style>
                        </StackPanel.Resources>

                        <Border Style="{StaticResource GroupBorder}">
                            <StackPanel Style="{StaticResource GroupPanel}">
                                <StackPanel Orientation="Horizontal">
                                    <Button x:Name="StartNewDiagram" ToolTip="Unloads all data and clears the diagram" >
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/ClearIcon.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Start New</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>

                                    <Button x:Name="LoadAssembly" ToolTip="Opens dialog for loading of .NET assembly">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/Blocks.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Load Assembly</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>

                                    <Button x:Name="LoadProjectFile" ToolTip="Opens dialog for loading of C# Visual Studio project">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/CsprojIncon.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Load Project</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>

                                    <Button x:Name="LoadSolutionFile" ToolTip="Opens dialog for loading of Visual Studio solution">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/VSIcon.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Load Solution</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>
                                </StackPanel>
                                <Border Style="{StaticResource GroupHeadingBorder}">
                                    <TextBlock Style="{StaticResource GroupHeading}">Diagram Manipulation</TextBlock>
                                </Border>
                            </StackPanel>
                        </Border>

                        <Border Style="{StaticResource GroupBorder}">
                            <StackPanel Style="{StaticResource GroupPanel}">
                                <StackPanel Orientation="Horizontal">
                                    <Button x:Name="ZoomOut"  ToolTip="Displays the diagram of parent element">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/GoUpIcon.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Up</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>

                                    <Button x:Name="Back" ToolTip="Go back to previous diagram">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/GoBackIcon.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Back</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>

                                    <Button x:Name="Forward" ToolTip="Go forward">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/GoForwardIcon.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Forward</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>
                                </StackPanel>
                                <Border Style="{StaticResource GroupHeadingBorder}">
                                    <TextBlock Style="{StaticResource GroupHeading}">Diagram Browsing</TextBlock>
                                </Border>
                            </StackPanel>
                        </Border>

                        <Border Style="{StaticResource GroupBorder}">
                            <StackPanel  Style="{StaticResource GroupPanel}">
                                <StackPanel Orientation="Horizontal">
                                    <Button x:Name="RunPatternEnforcer" ToolTip="Runs Pattern Enforcer and displays the results in errors window">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/RunIcon.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Run</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>
                                </StackPanel>
                                <Border Style="{StaticResource GroupHeadingBorder}">
                                    <TextBlock Style="{StaticResource GroupHeading}">Pattern Enforcer</TextBlock>
                                </Border>
                            </StackPanel>
                        </Border>

                        <Border Style="{StaticResource GroupBorder}">
                            <StackPanel  Style="{StaticResource GroupPanel}">
                                <StackPanel Orientation="Horizontal">
                                    <Button x:Name="ShowSettings" ToolTip="Opens settings dialog">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/Settings.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Settings</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>

                                    <Button x:Name="ShowAbout" ToolTip="Opens dialog with information about the application">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/AboutIcon.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">About</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>

                                    <Button x:Name="Exit" ToolTip="Closes the application">
                                        <Button.Template>
                                            <ControlTemplate>
                                                <Border Style="{StaticResource ButtonBorder}">
                                                    <StackPanel>
                                                        <Image Source="./../Image/ExitIcon.png" Style="{StaticResource ButtonImage}"/>
                                                        <TextBlock Style="{StaticResource ButtonHeading}">Exit</TextBlock>
                                                    </StackPanel>
                                                </Border>
                                            </ControlTemplate>
                                        </Button.Template>
                                    </Button>
                                </StackPanel>
                                <Border Style="{StaticResource GroupHeadingBorder}">
                                    <TextBlock Style="{StaticResource GroupHeading}">Help &amp; Exit</TextBlock>
                                </Border>
                            </StackPanel>
                        </Border>
                    </StackPanel>
                </StackPanel>
                
                <StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right">
                    <ToggleButton x:Name="ShowRibbon" IsChecked="True" ToolTip="Toggle the toolbar">
                        <ToggleButton.Resources>
                            <SolidColorBrush x:Key="ButtonBrush" Color="#FFFFFF"/>
                            <Style TargetType="ToggleButton">
                                <Style.Triggers>
                                    <Trigger Property="IsChecked" Value="True">
                                        <Setter Property="RenderTransform">
                                            <Setter.Value>
                                                <RotateTransform CenterX="11" CenterY="11" Angle="180"/>
                                            </Setter.Value>
                                        </Setter>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </ToggleButton.Resources>
                        <ToggleButton.Template>
                            <ControlTemplate TargetType="ToggleButton">
                                <Grid Name="MainGrid" Background="Transparent">
                                    <Viewbox>
                                        <Canvas Width="22" Height="22">
                                            <Ellipse Width="18"	Height="18" Canvas.Left="2" Canvas.Top="2"
										Stroke="{DynamicResource ButtonBrush}" 
										StrokeThickness="1.5"/>
                                            <Path Data="M 5,8 L 11,12 L 17, 8" StrokeThickness="1.5" Stroke="{DynamicResource ButtonBrush}"/>
                                            <Path Data="M 5,11 L 11,15 L 17, 11" StrokeThickness="1.5" Stroke="{DynamicResource ButtonBrush}"/>
                                        </Canvas>
                                    </Viewbox>
                                </Grid>
                            </ControlTemplate>
                        </ToggleButton.Template>
                    </ToggleButton>
                </StackPanel>
            </Grid>
        </Border>

        <ad:DockingManager x:Name="dockManager" Grid.Row="1">
            <ad:DockingManager.Resources>
                <Style TargetType="{x:Type ad:DocumentPane}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ad:DocumentPane}" >
                                <Border BorderThickness="2" 
                                        BorderBrush="#FFD6E2F8" 
                                        CornerRadius="3" 
                                        Margin="2, 2, 2, 2" 
                                        ad:ResizingPanel.ResizeWidth="*"
                                        Focusable="False">
                                    <ContentPresenter 
                                        Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem.Content}"
                                        Margin="2"/>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ad:DockingManager.Resources>

            <ad:ResizingPanel Orientation="Vertical">
                <ad:ResizingPanel Orientation="Horizontal">
                    <ad:DocumentPane ad:ResizingPanel.ResizeWidth="*">
                        <ad:DocumentContent Title="Diagram" IsCloseable="False">
                            <ContentControl x:Name="DiagramViewModel"/>
                        </ad:DocumentContent>
                    </ad:DocumentPane>

                    <ad:DockablePane ad:ResizingPanel.ResizeWidth="150">
                        <ad:DockableContent x:Name="classesContent" Title="Diagram" 
                                            ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                            ScrollViewer.VerticalScrollBarVisibility="Auto">
                                <ContentControl x:Name="DiagramBrowser"/>
                        </ad:DockableContent>
                        <ad:DockableContent x:Name="patternDocumentationContent" Title="Pattern Documentation">
                            <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> 
                                <ContentControl x:Name="PatternDocumentation"/>
                            </ScrollViewer>
                        </ad:DockableContent>
                        <ad:DockableContent Title="Properties">
                            <ContentControl x:Name="DetailPanel"/>
                        </ad:DockableContent>                        
                    </ad:DockablePane>
                </ad:ResizingPanel>
                <ad:DockablePane ad:ResizingPanel.ResizeHeight="100">
                    <ad:DockableContent Title="Errors" x:Name="errorsContent">
                        <ContentControl x:Name="ErrorsWindow"/>
                    </ad:DockableContent>
                    <ad:DockableContent Title="Output Window">
                        <ContentControl x:Name="OutputWindow"/>
                    </ad:DockableContent>
                </ad:DockablePane>
            </ad:ResizingPanel>
        </ad:DockingManager>

        <StatusBar Grid.Row="2">
            <StatusBarItem Content="Patterns4Net Architecture Explorer"/>
            <StatusBarItem HorizontalContentAlignment="Right">
                <ProgressBar IsIndeterminate="True" Width="250" Height="16" Visibility="Hidden"/>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>
